import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'userName',
    width: 120,
  },
  {
    title: '国内手机号',
    dataIndex: 'userPhone',
    width: 120,
  },
  {
    title: '邮箱',
    dataIndex: 'email',
    width: 120,
  },
  {
    title: '是否默认',
    dataIndex: 'isDef',
    width: 120,
    customRender: ({ record }: Recordable) => {
      const isDefArray = [
        { label: '是', value: 1 },
        { label: '否', value: 2 },
      ];
      const isDef: any = isDefArray.find((item) => item.value == record.isDef);
      if (isDef) {
        return isDef.label;
      }
      return '';
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 120,
  },
];

export const searchFormSchema: FormSchema[] = [];

export const formSchema: FormSchema[] = [
  {
    label: '主键',
    field: 'contactsId',
    component: 'Input',
    required: false,
    show: false,
  },
  {
    label: '用户id',
    field: 'userId',
    component: 'Input',
    required: true,
    show: false,
  },
  {
    label: '姓名',
    field: 'userName',
    component: 'Input',
    required: true,
  },
  {
    label: '国内手机号',
    field: 'userPhone',
    component: 'Input',
    required: true,
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    required: true,
  },
  {
    label: '是否默认',
    field: 'isDef',
    component: 'RadioButtonGroup',
    required: true,
    defaultValue: 2,
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 2 },
      ],
    },
  },
];
